package com.leetcode.LC;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class LC830 {
    public List<List<Integer>> largeGroupPositions(String s) {

        if (s.length() < 3) {
            return new ArrayList<List<Integer>>();
        }
        List<List<Integer>> lists = new ArrayList<>();
        int a = 0, b = 0, count = 0;
        while (a < s.length()) {
            if (b < s.length() && s.charAt(a) == s.charAt(b)) {
                b++;
            } else {
                count = b - a;
                if (count >= 3) {
                    lists.add(Arrays.asList(a, b-1));
                }
                a = b;
            }
        }
        return lists;
    }

    public static void main(String[] args) {
        for (List<Integer> list : new LC830().largeGroupPositions("abbxxxxzzyyyabcdddeeeeaabbbcd")) {
            for (Integer integer : list) {
                System.out.print(integer + ",");
            }
            System.out.println();
        }
    }

}
